package STUDENT.NGUYENHUUTHANG.MVC.B2;

import java.util.Scanner;

public class Views {

	public static void main(String[] args) {
		System.out.println("Nhap vao so a = ");
		NumberObject objObject = new NumberObject();
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		if (x.isEmpty()) {
			System.out.println("Bạn chưa nhập số a!");
		} else
			System.out.println("Nhap vao so a = ");
		String y = sc.nextLine();
		if (y.isEmpty()) {
			System.out.println("Bạn chưa nhập số b!");
		} else
			System.out.println("Chọn phép toán: ");
		String z = sc.nextLine();
		if (z.isEmpty() || (z.equals("+") == false && z.equals("-") == false && z.equals("*") == false
				&& z.equals("/") == false)) {
			System.out.println("Ban chua chon phep toan hoac chon sai phep toan!");
		} else {
			double a = Double.parseDouble(x);
			double b = Double.parseDouble(y);
			objObject.setA(a);
			objObject.setB(b);
			objObject.setPheptoan(z);
			Controllers objController = new Controllers();
			if (objObject.getPheptoan().equals("/")) {
				if (objObject.getA() == 0 && objObject.getB() == 0) {
					System.out.println("Result of function is underfined");
				} else if (objObject.getA() != 0 && objObject.getB() == 0) {
					System.out.println("Cannot divide by zero");
				} else
					System.out.println("Kết quả là: " + objController.ExecOf_Calc(objObject));

			} else System.out.println("Kết quả là: "+ objController.ExecOf_Calc(objObject));	
		
		}

	}

}
